package com.lazily.stringbuffer_;


/**
 * @Author:  GZQ
 * @date:  2025/3/12 22:34
 * @description: StringBuffer 的练习1
 */

public class StringBufferExercise01 {
	// 程序入口
	public static void main(String[] args) {
		String str = null;// ok
		StringBuffer sb = new StringBuffer(); //ok
		sb.append(str);//需要看源码 , 底层调用的是 AbstractStringBuilder 的 appendNull
		System.out.println(sb.length());//4
		System.out.println(sb);//null


		//下面的构造器，会抛出 NullpointerException
		StringBuffer sb1 = new StringBuffer(str);//看底层源码 super(str.length() + 16);
		System.out.println(sb1);
	}
}
